package com.dm.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.dm.entity.Manager;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dm.entity.Room;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author dancun
 * @since 2021-05-02
 */
@Mapper
@Repository
public interface ManagerMapper extends BaseMapper<Manager> {
    @Results(id = "baseMap" ,value = {
            @Result(column="did",property="dormitory",one=@One(select="com.dm.mapper.DormitoryMapper.selectById",fetchType= FetchType.EAGER)),
            @Result(column="did",property="did")
    })

    @Select("select * from manager ${ew.customSqlSegment}")
    public List<Manager> listManager(@Param(Constants.WRAPPER) QueryWrapper wrapper);

    @ResultMap(value = "baseMap")
    @Select("select * from manager where id = #{id}")
    public Manager getOneManager(Integer id);

    @ResultMap(value = "baseMap")
    @Select("select * from manager where did = #{did}")
    public Manager getByDID(Integer did);

}
